<?php
require 'BinarySearchTreeMap.php';
require $root . "/MinHeap/MinHeap.php";
$nums = [5,-3,9,1,7,7,9,10,2,2,10,10,3,-1,3,7,-9,-1,3,3];
$k   = 3;
$map = new BinarySearchTreeMap();
foreach ($nums as $key) {
    $value = $map->get($key);
    if ($value != null) {
        $map->set($key, $value + 1);
    } else {
        $map->add($key, 1);
    }
}
$minHeap = new MinHeap();
$map->traverseMinHeap($minHeap, $k);

//print_r($minHeap);
$reArr = [];
while (!$minHeap->isEmpty()) {
    $arr = $minHeap->getMin();
    $reArr[] = $arr["key"];
}
print_r($reArr);


